package com.smartthinking.CICPNL.home.activity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.smartthinking.CICPNL.R;

public class Navegador extends Activity {

	public String URL_video;
	public WebView browser;
	
	public void voidFinish(View v){
		finish();
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.ui_activity_navegador);
		
		Bundle extras = getIntent().getExtras();
		if (extras!=null){
			Utilities util = new Utilities();
						
			URL_video = extras.getString("video_URL");
			Log.i("URL", ""+URL_video);
			browser = (WebView) findViewById(R.id.web_browser);
			
			browser.getSettings().setJavaScriptEnabled(true);
			browser.getSettings().setPluginsEnabled(true);
			browser.setWebViewClient(new WebViewClient() {
				@Override
				public boolean shouldOverrideUrlLoading(WebView view, String url) {
					view.loadUrl(url);
					return true;
				}
			});
			browser.loadUrl(URL_video);
			
			
			
			  
//		       String htmlString = "<html> <body> <embed src=\"" + URL_video + "\" ; type=application/x-shockwave-flash> </embed> </body> </html>";
//		       util.alert(this, "Ejecutando: " + htmlString);
//		       browser.loadData(htmlString ,"text/html", "UTF-8");
			
//			browser.getSettings().setJavaScriptEnabled(true);
//			browser.getSettings().setBuiltInZoomControls(true);
//			browser.setWebChromeClient(new WebChromeClient());
//			browser.getSettings().setPluginsEnabled(true);
//		    browser.addJavascriptInterface(this, "jsNativeInterface");			
//		    browser.loadUrl(URL_video);
		    			
		}
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.ui_activity_navegador, menu);
		return true;
	}
	
	public void voidfinish(View v){
		finish();
	}

}
